import { defineConfig } from 'vite'
import vue from '@vitejs/plugin-vue'
import jsx from '@vitejs/plugin-vue-jsx'
import path from 'path'
import { adminConfig } from "../model/src/index"

// https://vitejs.dev/config/
export default defineConfig({
  css: {
    preprocessorOptions: {
      // 全局样式引入
      scss: {
        additionalData: '@import "./src/styles/var.scss";'
      }
    }
  },
  server: {
    host: '127.0.0.1',
    port: adminConfig.port,
    hmr: true,
    proxy: {
      "/api": {
        target: "http://127.0.0.1:6005",
        changeOrigin: true,
        rewrite: (path) => path.replace(/^\/api/, '')
      }
    }
  },
  plugins: [
    vue(),
    jsx()
  ],
  resolve: {
    alias: {
      "@": path.resolve(__dirname, 'src')
    }
  },
})
